package inline;

import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Build;
import android.os.PowerManager;
import android.provider.Settings;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;

import com.ss.android.newmedia.a.MediaItem;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

public class PackageUtils {
    public static boolean a(Context arg2, Intent arg3) {
        boolean v0 = false;
        if (arg2 != null) {
            try {
                if (arg3.resolveActivity(arg2.getPackageManager()) == null) {
                    return v0;
                }
            } catch (Throwable v1) {
                return v0;
            }

            v0 = true;
        }

        return v0;
    }

    public static boolean a(Context arg5, String arg6) {
        boolean v0_4;
        if (arg5 != null && !TextUtils.isEmpty(((CharSequence) arg6))) {
            try {
                Object v0_1 = arg5.getSystemService(Context.ACTIVITY_SERVICE);
                if (Build.VERSION.SDK_INT < 21) {
                    List<ActivityManager.RunningTaskInfo> v0_2 = ((ActivityManager) v0_1).getRunningTasks(1);
                    if (!v0_2.isEmpty()) {
                        ComponentName v0_3 = v0_2.get(0).topActivity;
                        if (v0_3 == null) {
                            return false;
                        } else if (arg6.equals(v0_3.getPackageName())) {
                            v0_4 = true;
                            return v0_4;
                        } else {
                            return false;
                        }
                    } else {
                        return false;
                    }
                } else {
                    Iterator v1 = ((ActivityManager) v0_1).getRunningAppProcesses().iterator();
                    do {
                        if (v1.hasNext()) {
                            v0_1 = v1.next();
                            if (((ActivityManager.RunningAppProcessInfo) v0_1).importance != 100) {
                                continue;
                            }

                            break;
                        } else {
                            return false;
                        }
                    }
                    while (true);

                    return arg6.equals(((ActivityManager.RunningAppProcessInfo) v0_1).pkgList[0]);
                }
            } catch (Throwable v0) {
            }

            label_39:
            v0_4 = false;
        } else {
            label_5:
            v0_4 = false;
        }

        return v0_4;
    }

    public static boolean i(Context arg4) {
        Iterator v1 = ((ActivityManager) arg4.getSystemService(Context.ACTIVITY_SERVICE)).getRunningAppProcesses().iterator();
        do {
            if (v1.hasNext()) {
                Object v0 = v1.next();
                if (((ActivityManager.RunningAppProcessInfo) v0).importance != 100) {
                    continue;
                }

                if (!((ActivityManager.RunningAppProcessInfo) v0).processName.equals(arg4.getApplicationInfo().processName)) {
                    continue;
                }

                break;
            } else {
                return false;
            }
        }
        while (true);

        boolean v0_1 = true;
        return v0_1;
    }

    public static boolean j(Context arg3) {
        Object v0 = arg3.getSystemService(Context.POWER_SERVICE);
        boolean v0_1 = Build.VERSION.SDK_INT >= 21 ? ((PowerManager) v0).isInteractive() : ((PowerManager) v0).isScreenOn();
        return v0_1;
    }

    public static String k(Context arg4) {
        int v3 = -1;
        Intent v0 = arg4.registerReceiver(null, new IntentFilter("android.intent.action.BATTERY_CHANGED"));
        String v0_1 = v0 == null ? "batteryStatus error" : String.valueOf((((float) v0.getIntExtra("level", v3))) / (((float) v0.getIntExtra("scale", v3))));
        return v0_1;
    }

    @SuppressLint(value = {"HardwareIds", "MissingPermission"})
    public static String h(Context arg1) {
        String v0_1;
        try {
            v0_1 = ((TelephonyManager) arg1.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId();
        } catch (Exception v0) {
            v0.printStackTrace();
            v0_1 = null;
        }

        return v0_1;
    }

    @SuppressLint(value = {"HardwareIds"})
    public static String g(Context arg2) {
        String v0_1;
        try {
            v0_1 = Settings.Secure.getString(arg2.getContentResolver(), "android_id");
        } catch (Exception v0) {
            v0.printStackTrace();
            v0_1 = null;
        }

        return v0_1;
    }

    @SuppressLint(value = {"HardwareIds", "MissingPermission"})
    public static String[] f(Context arg5) {
        String[] v1_1 = null;
        List<SubscriptionInfo> v3;
        int v2 = 0;
        String[] v0 = null;
        if (arg5 == null) {
            return v0;
        }

        try {
            if (Build.VERSION.SDK_INT < 22) {
                v1_1 = new String[1];
                v1_1[0] = ((TelephonyManager) arg5.getSystemService(Context.TELEPHONY_SERVICE)).getSimSerialNumber();
                return v1_1;
            }

            v3 = SubscriptionManager.from(arg5).getActiveSubscriptionInfoList();
            if (v3 == null) {
                return v0;
            }

            if (v3.isEmpty()) {
                return v0;
            }

            v1_1 = new String[v3.size()];
            while (v2 < v3.size()) {
                v1_1[v2] = v3.get(v2).getIccId();
                ++v2;
            }
        } catch (Throwable v0_1) {
            v0_1.printStackTrace();
        }

        return v1_1;
    }

    public static boolean a(Context arg4) {
        try {
            NetworkInfo v0_1 = ((ConnectivityManager) arg4.getSystemService(Context.CONNECTIVITY_SERVICE)).getActiveNetworkInfo();
            if (v0_1 == null || !v0_1.isAvailable()) {
                boolean v0_2 = false;
                return v0_2;
            }

            if (1 != v0_1.getType()) {
                return false;
            }
        } catch (Exception v0) {
            return false;
        }

        return true;
    }

    public static boolean b(Context arg4, String arg5) {
        boolean v0 = false;
        if (!TextUtils.isEmpty(((CharSequence) arg5)) && arg4 != null) {
            try {
                Intent v2 = new Intent("com.ss.android.sdk." + Uri.parse(arg5).getScheme());
                v2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                if (com.ss.android.lockscreen.bb.a().g) {
                    v2.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
                }

                if (!IntentUtils.a(arg4, v2)) {
                    return v0;
                }

                v2.putExtra("open_url", arg5);
                arg4.startActivity(v2);
                v0 = true;
            } catch (Exception v1) {
            }
        }

        return v0;
    }

    public static List a(List arg6, List arg7) {
        String v4;
        Object v0;
        ArrayList v1 = new ArrayList();
        if (arg7 == null || (arg7.isEmpty())) {
            arg7 = v1;
        } else if (arg6 != null && !arg6.isEmpty()) {
            HashMap v2 = new HashMap();
            new HashMap();
            Iterator v3 = arg7.iterator();
            while (v3.hasNext()) {
                v0 = v3.next();
                v4 = ((MediaItem) v0).getItemKey();
                if (((MediaItem) v0).skipDedup()) {
                    continue;
                }

                if (android.support.design.a.isTextEmpty(v4)) {
                    continue;
                }

                if (v2.containsKey(v4)) {
                    continue;
                }

                v2.put(v4, v0);
            }

            v3 = arg6.iterator();
            while (v3.hasNext()) {
                v0 = v3.next();
                v4 = ((MediaItem) v0).getItemKey();
                if (((MediaItem) v0).skipDedup()) {
                    ((List) v1).add(v0);
                } else {
                    if (v2.containsKey(v4)) {
                        continue;
                    }

                    v2.put(v4, v0);
                    ((List) v1).add(v0);
                }
            }

            arg6.clear();
            arg6.addAll(v1);
        }

        return arg7;
    }




}
